Repository navigation
fix(mobile): keep dictation recording through a reconnect and keep what was already said - #35338
Conversation
[Medium impact] The changes affect mobile dictation and the reconnect paths it uses. The lost-reply finding remains partly unfixed and should be addressed before merging. SummaryKeeps mobile dictation alive across reconnects and saves received transcript text when recording fails.
|
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
The host tied a phone's dictation to its socket, so any reconnect cancelled it, and the phone ended the recording as soon as the connection dropped. The host now owns the session by device and waits a grace period for the phone to come back. The phone keeps recording through the reconnect and keeps the text transcribed so far if the connection does not return. Fixes #35211
…e and send the text so far only when it changes
…und the start wait
…n and share the reconnect wait
fea5cb5 to
4249db6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
82b00dbc-b410-435f-a1d3-d71fec00fd11
Files selected for processing: 12-
mobile/rpc-foundation/goldens/matrix-speech.dictation-session-speech.dictation.finish-1.jsonmobile/rpc-foundation/goldens/matrix-speech.dictation-session-speech.dictation.start-1.jsonmobile/rpc-foundation/goldens/matrix-speech.dictation-start-speech.dictation.cancel-1.jsonmobile/rpc-foundation/goldens/matrix-speech.dictation-start-speech.dictation.start-1.jsonmobile/rpc-foundation/goldens/speech-desktop-start-recording-failed.jsonmobile/rpc-foundation/goldens/speech-desktop-start-superseded.jsonmobile/rpc-foundation/goldens/speech-dictation-session-cancelled.jsonmobile/src/hooks/mobile-dictation-desktop-start.test.tsmobile/src/hooks/mobile-dictation-desktop-start.tsmobile/src/hooks/use-mobile-dictation.tssrc/main/runtime/runtime-mobile-dictation-controller.test.tssrc/main/runtime/runtime-mobile-dictation-controller.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
ELI5
If your phone's connection blinked while you were dictating to Orca Mobile, the recording stopped and everything you'd said was gone. Now the phone keeps recording through the reconnect and you get the whole transcript. If the connection never comes back, you keep whatever was already transcribed.
What Changed
Before: any reconnect mid-dictation ended it. That covers a Wi-Fi/cellular switch, a Relay hiccup or a direct→Relay fallback. The mic stopped, the speech was lost and sometimes a raw code like
dictation_owner_mismatchshowed up.After: the recording carries on through the reconnect and stop gives the full transcript. If the phone can't get back within 30s, dictation ends with an error but the words transcribed so far land in the input.
Root cause: the host tied a phone's dictation session to the socket rather than to the phone. A socket close cancelled the session, and requests from the reconnected socket were refused as
dictation_owner_mismatch. The phone also gave up on its own:enabledfollowedconnState === 'connected', so the first drop abandoned the recording, and any chunk error ended it.Host (
runtime-mobile-dictation-controller.ts):clientId. Socket and client disconnect hooks no longer cancel it.MOBILE_DICTATION_RECONNECT_GRACE_MS, shared inspeech-params.ts), the speech model is released. This covers a killed app, a lost cancel, or a phone that never comes back.text) when it changed, and at least once a second so a reply lost at the drop is replaced. This is additive: old phones ignore the reply body.Phone:
failWhenDisconnected); the host's idle timer drops a session the phone can't reach.Why
The fix sits at the host's session lifetime, where the wrong fact lived ("this dictation belongs to that socket"). Phone-side retries alone can't work, because the host has already thrown the session away. The phone changes only stop treating a reconnect as the end of input, and resend requests that provably never reached the host.
What can still be lost: speech sent on the dying connection before the phone notices the drop. Those chunks may or may not have reached the host, so they aren't replayed (that would duplicate words). That's about 1s on a hard drop, and more on a silent drop until the liveness probe fires. Replaying them safely needs sequence numbers the host can dedupe, gated on a new capability: #35213.
Mixed versions:
textin chunk replies is ignored. The old phone still abandons on a drop and sends cancel, which now matches byclientIdand goes through.dictation_stream_not_started) or after 30s, the same loss as today but reported later. I didn't add a capability gate for that, since the outcome is no worse than today.Linked Issue
Fixes #35211
Follow-up: #35213 (replay speech sent on the dying connection)
Visual Proof
N/A: there's no new UI, and the change is about what happens across a network drop. Staging a timed Wi-Fi/Relay drop mid-dictation on a simulator doesn't reproduce it reliably. The behaviour is covered by hook, transport and host tests that each fail on the old code (listed below), plus the mobile RPC recording goldens.
Testing
Host:
runtime-mobile-dictation-controller.test.ts. It shows that the session survives a phone that keeps reaching it from any connection and returns the full transcript, and that it releases the model after 30s of silence. Plusspeech.test.tsandorcad-speech-services.test.ts.Phone hook:
mobile-dictation-reconnect.test.tsx. It covers chunks lost at the drop not ending the recording, cutover-unsent chunk and finish requests being resent, a suspended-client refusal being held until reconnect (including the bridge-rebuilt error), and the transcribed text being kept when the connection never returns.Session:
mobile-dictation-agent-chat-start.test.tsx. A start and a finish that span a drop both complete.Terminal mic:
mobile-dictation-disabled-controls.test.tsx. The mic can still stop a recording while offline.Transport:
mobile-relay-rpc-session.test.ts: retiring a failed session releases waiting requests unsent.stable-logical-rpc-client.test.ts: requests interrupted by suspension are reported as suspended, and written ones stay ambiguous.Every new test was checked to fail with its fix reverted.
Mobile RPC recording goldens re-recorded for the chunk reply handling and the new
timeoutMson start and chunk; all 1695 pass.Changed-file code-quality and react-doctor gates pass. CI covers the full suite and typecheck.
No device or simulator run.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Four review rounds with Codex and Claude. Every accepted P0/P1 was fixed with a test:
Not taken:
To try (needs blessing: changes host/phone behaviour):
/Users/kelvinamoaba/orca/workspaces/orca/dictation-reconnect(both desktop and mobile change).Agent skill upstream boundary
Notes
orca servehosts use the same controller.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)